#include <iostream>
#define N 100

using namespace std;

int gcd(int a, int b){
if ((a%b)==0)
        return b;
    else
        return gcd(b,a%b);
}

int isprime(int a, int b){
 if(gcd(a, b)==1)
  return 1;
return 0;
}

void prime_with_k(int array[], int elements, int k){
int i;
for(i=0;i<elements;i++)
    if(isprime(array[i], k))
        cout<<array[i]<<" ";
cout<<"\n";
}


void readintVector(int array[], int elements){
for (int i=0; i<elements; i++){
	cout<<"a["<<i<<"]=";
	cin>>array[i];
	cout<<"\n";}
}

void printintVector(int array[], int elements){
for(int i=0; i<elements; i++){
	cout<<array[i]<<" ";}
	cout<<"\n";
}

int main(){
int array[N];
int elements;
int k;
int pr[N];

cout<<"Type the number of elements you want in the array: ";
cin>>elements;

readintVector(array, elements);

cout<<"Type the number to test prime relationship: ";
cin>>k;

cout<<"The original array is ";
for(int i=0; i<elements; i++){
	cout<<array[i]<<" ";}
cout<<endl;


cout<<"The following elements are prime with "<< k<<":";
prime_with_k(array,elements, k);

return 0;

}
